<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>增加用户</title>

    <meta charset="UTF-8">

    <script src="../../../js/jquery-2.0.3.min.js"></script>
    <link rel="stylesheet" href="../../../css/bootstrap.min.css">
    <script src="../../../js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="../../../css/bootstrapValidator.css">
    <script src="../../../js/bootstrapValidator.js"></script>
    <script src="../../../js/jquery.cookie.js"></script>
    <script src="https://unpkg.com/vue/dist/vue.js"></script>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <script src="../../../js/hostConfig.js"></script>


</head>
<body>
<div class="container kv-main" id="app">

    <div class="jumbotron">
        <h1>后台首页</h1>
        <p><a href="/pages/manage/role/list.html">角色列表</a></p>
    </div>

    <form name="form" action="/role/add/submit" method="post" enctype="multipart/form-data" class="form-horizontal">

        <div class="form-group">
            <label class="col-lg-1 control-label">用户ID</label>
            <div class="col-lg-6">
                <input type="text" id="id" name="name" class="form-control" placeholder="用户ID" v-model="user.id" disabled>
            </div>
        </div>

        <div class="form-group">
            <label class="col-lg-1 control-label">名称</label>
            <div class="col-lg-6">
                <input type="text" id="name" name="name" class="form-control" placeholder="用户名称" v-model="user.name"/>
            </div>
        </div>

        <!--<div class="form-group">-->
            <!--<label class="col-lg-1 control-label">描述</label>-->
            <!--<div class="col-lg-6">-->
                <!--<input type="text" id="description" name="description" class="form-control" placeholder="角色描述"-->
                       <!--v-model="role.description"/>-->
            <!--</div>-->
        <!--</div>-->

        <div class="form-group">
            <label class="col-lg-1 control-label">拥有角色</label>

            <div class="col-lg-6">
                <div>
                    <label>
                        <table class="table table-hover">
                            <thead>
                            <tr>
                                <th>名称</th>
                                <th>描述</th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr v-for="p in todos">
                                <td>
                                    <span v-text="p.name"></span>
                                </td>

                                <td>
                                    <span v-text="p.description"></span>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </label><br>
                </div>
            </div>
        </div>

    </form>
</div>

</body>
</html>

<script>
    var app = new Vue({
        el: '#app',
        data: {
            id:"",
            name: "",
            description: "",
            permissions: [],
            todos: [],
            user: {},
        },
        mounted() {
            this.id = this.$options.methods.getUrlParam('id');
            axios({method: 'post', url: host_tomcatR+'/user/queryUserById?id=' + this.id, withCredentials: true}).then(res => this.user = res.data);
            axios({method: 'post', url: host_tomcatR+'/user/queryRolesByUserId?id=' + this.id, withCredentials: true}).then(res => this.todos = res.data);
        },
        methods: {
            getUrlParam: function (key) {
                var reg = new RegExp(key + '=([^&]*)');
                var results = location.href.match(reg);
                return results ? results[1] : null;
            }
        }

    });
</script>
